﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
           elementFormDefault="qualified"
           targetNamespace="http://dataaccessor.codeplex.com/xsd/Mapping"
           xmlns= "http://dataaccessor.codeplex.com/xsd/Mapping"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Mapping">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="Type">
          <xs:complexType mixed="true">
            <xs:sequence minOccurs="0">
              <xs:element maxOccurs="unbounded" name="Property">
                <xs:complexType>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                  <xs:attribute name="Field" type="xs:string" use="required" />
                  <xs:attribute name="DataType"  type="DataTypeRestriction" use="optional" default="string" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="Alias" type="xs:string" use="required" />
            <xs:attribute name="Type" type="xs:string" use="required" />
            <xs:attribute name="Assembly" type="xs:string" use="optional"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!--属性的数据类型约束-->
  <xs:simpleType name="DataTypeRestriction">
    <xs:restriction base="xs:string">
      <xs:enumeration value="decimal"/>
      <xs:enumeration value="float"/>
      <xs:enumeration value="int"/>
      <xs:enumeration value="short"/>
      <xs:enumeration value="byte"/>
      <xs:enumeration value="bool"/>
      <xs:enumeration value="long"/>
      <xs:enumeration value="string"/>
      <xs:enumeration value="System.Guid"/>
      <xs:enumeration value="System.DateTime"/>
      <xs:enumeration value="System.DateTimeOffset"/>
      <xs:enumeration value="object"/>
      <xs:enumeration value="byte[]"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>